import Vue from 'vue'
import VueRouter from 'vue-router'
// import PathArr from '@/router/pathArr.js'

// 添加需要的组件
import Login from '@/components/MyLogin.vue'
import Home from '@/components/MyHome.vue'
import Main from '@/components/MyMain.vue'

import Users from '@/components/menus/MyUsers.vue'
import Roles from '@/components/menus/MyRoles.vue'
import Menus from '@/components/menus/MyMenus.vue'



Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/login', component: Login },

    {
      path: '/home', component: Home,
      //redirect: '/home/users',
      children: [

        { path: '/', redirect: '/users' },
        { path: '/users', component: Users },
        { path: '/roles', component: Roles },
        { path: '/menus', component: Menus },
        { path: '/main', component: Main },
      ]
    }
  ]
})

// 全局前置守卫
// router.beforeEach(function (to, from, next) {
//   if (PathArr.indexOf(to.path) !== -1) {
//     const token = localStorage.getItem('token')
//     if (token) {
//       next()
//     } else {
//       next('/login')
//     }
//   } else {
//     next()
//   }
// })




export default router
